package com.loop.unclelend.ui.adapter

import androidx.recyclerview.widget.RecyclerView
import com.loop.unclelend.R
import com.loop.unclelend.utils.adapter.UncleRecyclerViewAdapter
import com.loop.unclelend.utils.adapter.UncleViewHolderHelper
import org.json.JSONObject

/**
 * UncleLend
 * @Author wwdeng
 * @CreateTime: 2024/9/14 16:42
 * @Annotation：客服适配器
 */
class Adapter_Kefu(recyclerView: RecyclerView?) : UncleRecyclerViewAdapter<JSONObject>(recyclerView, R.layout.uncle_item_kefu) {
    override fun setItemChildListener(helper: UncleViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.btn_fun) //拨号、复制
    }

    override fun fillData(helper: UncleViewHolderHelper, position: Int, model: JSONObject) {
        helper.setText(R.id.txt_value,model.optString("value"))
        val imgType = helper.getImageView(R.id.img_type)
        val type = model.optString("type")
        when(type){
            "MOBILE" -> {//电话
                helper.setText(R.id.txt_title,mContext.getString(R.string.dialog_kefu_mobile_title))
                helper.setText(R.id.textType,mContext.getString(R.string.dialog_kefu_dial))
                imgType.setImageResource(R.mipmap.icon_kefu_mobile)
            }
            else -> {//邮箱
                helper.setText(R.id.txt_title,mContext.getString(R.string.dialog_kefu_email_title))
                helper.setText(R.id.textType,mContext.getString(R.string.dialog_kefu_copy))
                imgType.setImageResource(R.mipmap.icon_kefu_email_copy)
            }
        }
    }
}